#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

/**
 * 
 * pow(2,5) = 2^5
 *  
 */

int Transfer2Decimal(const std::string& num, int base) {
    int result = 0;
    int weight = 0;
    for (int i = num.size() - 1; i >= 0; i--) {
        int digit;
        if (num[i] >= '0' && num[i] <= '9') {
            digit = num[i] - '0';
        }
        else {
            digit = num[i] - 'A' + 10;
        }
        result += digit * (int)std::pow(base, weight++);
    }

    return result;
}

int FindStartBase(const std::string& p, const std::string& q, const std::string& r) {
    char maxChar = '0';
    for (int i = 0; i < p.size(); i++) {
        maxChar = std::max(maxChar, p[i]);
    }

    for (int i = 0; i < q.size(); i++) {
        maxChar = std::max(maxChar, q[i]);
    }

    for (int i = 0; i < r.size(); i++) {
        maxChar = std::max(maxChar, r[i]);
    }

    if (maxChar >= '0' && maxChar <= '9') {
        return maxChar - '0' + 1;
    }

    return maxChar - 'A' + 11;

}

/*
确定进制
*/
int main() {

    std::string p, q, r;

    std::cin >> p >> q >> r;

    bool find = false;

    int B = FindStartBase(p, q, r);
    for (; B <= 16; B++) {
        int p10 = Transfer2Decimal(p, B);
        int q10 = Transfer2Decimal(q, B);
        int r10 = Transfer2Decimal(r, B);

        if (p10 * q10 == r10) {
            find = true;
            break;
        }
    }

    if (find) {
        std::cout << B << std::endl;
    }
    else {
        std::cout << "0" << std::endl;
    }


    return 0;
}